package com.itheima.mapper;


import com.itheima.pojo.EmQueryParam;
import com.itheima.pojo.Emp;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper // 告诉MyBatis这是一个Mapper接口
public interface EmpMapper {


    public List<Emp> list(EmQueryParam emQueryParam);    //条件查询员工信息

    @Options(useGeneratedKeys = true, keyProperty = "id")//插入成功后，将主键值回填到emp对象中
    @Insert("insert into emp(username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time) " +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp); //新增员工基本信息


    void deleteByIds(List<Integer> ids);

    Emp getById(Integer id);

    void updateById(Emp emp);

    @MapKey("pos")//告诉MyBatis将结果集的哪一列作为Map的key
    List<Map<String, Object>> countEmpJobData();

    @MapKey("pos")
    List<Map> countEmpGenderData();

    Integer getCountById(Integer id);

    Emp getUsernameAndPassword(Emp emp);
}
